<?php
function thumbimg($filename,$w,$h){
		import('ORG.Util.Image.ThinkImage');
		$img = new ThinkImage(THINKIMAGE_GD, $filename); 
		$extarr = explode(".",$filename);
		$ext = end($extarr);
		$thumb = "./Public/Uploads/".date('Ymd')."/".guid().".".$ext;
		$img->thumb($w, $h,THINKIMAGE_THUMB_FILLED)->save($thumb);
		return $thumb;
}

function guid() 
{

	if (function_exists('com_create_guid'))
	    {

	        $uuid =  com_create_guid();

	        $uuid = str_replace("{", "", $uuid);

			$uuid = str_replace("}", "", $uuid);

			return strtolower($uuid);
	    }else{
	        mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
	        $charid = strtoupper(md5(uniqid(rand(), true)));
	        $hyphen = chr(45);// "-"
	        $uuid =  substr($charid, 0, 8).$hyphen
	                .substr($charid, 8, 4).$hyphen
	                .substr($charid,12, 4).$hyphen
	                .substr($charid,16, 4).$hyphen
	                .substr($charid,20,12);
	        return strtolower($uuid);
    }
}

function uuid() 
{
	mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
	$charid = strtolower(md5(uniqid(rand(), true)));
	return $charid;
}